package com.itany.ums;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/index")
public class IndexServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        DBUtil util = new DBUtil();
        List<User> users = util.selectAll();
        // 将数据存储到request作用域中
        req.setAttribute("users",users);

        // 转发到页面
        req.getRequestDispatcher("index.jsp").forward(req,resp);
    }
}
